<!DOCTYPE html>
<html>
<import file="block/common.html" name="header"/>
<body>
<import file="block/common.html" name="nav"/>

<div class="layui-container">
	<div class="layui-card">
		<div class="layui-card-body cxuu_top_info">
		    写意见反馈：
		</div>
	</div>
   
 <div id="cxuu_main">   
	<form class="layui-form" action="" lay-filter="">
		<div class="layui-form-item">
		  <label class="layui-form-label">意见标题</label>
		  <div class="layui-input-block">
			<input type="text" name="title" lay-verify="title" autocomplete="off" placeholder="请输入标题" class="layui-input" value="测试提交意见">
		  </div>
		</div>
		<div class="layui-form-item">
			<label class="layui-form-label">您的姓名</label>
			<div class="layui-input-inline">
			  <input type="text" name="name" lay-verify="name" autocomplete="off" placeholder="请输入您的姓名" class="layui-input" value="张三">
			</div>
		</div>
		<div class="layui-form-item">
			<label class="layui-form-label">手机号</label>
			<div class="layui-input-block">
			  <input type="text" name="phone" lay-verify="phone" autocomplete="off" placeholder="请输入手机号" class="layui-input" value="13888888888">
			</div>
		</div>

		<div class="layui-form-item layui-form-text">
		  <label class="layui-form-label">意见内容</label>
		  <div class="layui-input-block">
			<textarea placeholder="请输入内容" lay-verify="content" class="layui-textarea" name="content">测试提交意见内容测试提交意见</textarea>
		  </div>
		</div>
		<div class="layui-form-item layui-form-text">
		  <label class="layui-form-label">验证码</label>
		  <div class="layui-input-inline">
			<input type="text" name="vercode" lay-verify="required" autocomplete="off" placeholder="请输入验证码" class="layui-input" value="" lay-reqtext="验证码不能为空">
		  </div>
		  <div class="layui-input-inline">
			<img id="recode" src="/feedback/vercode">
		  </div>
		</div>
	   
		<div class="layui-form-item">
		  <div class="layui-input-block">
			<input type="hidden" name="mid" value="1" id="mid">
			<button type="submit" class="layui-btn" lay-submit="" lay-filter="saveBtn">立即提交</button>
		  </div>
		</div>
	</form>
  </div>
</div>
         
<script src="<?php echo U_RES;?>/lib/layui/layui.js" charset="utf-8"></script>
<script>
layui.use(['form','element','jquery'], function(){
	var element = layui.element,
	$ = layui.jquery,
	form = layui.form;
	form.render();
	//表单验证规则
	form.verify({
		title: function(value){
			if(value.length < 5){
				return '标题不能少于5个字符';
			}
		}
		,content: function(value){
			if(value.length < 10){
				return '内容不能少于10个字符';
			}
		}
	});

	var codeSrc = '/feedback/vercode';
	//监听提交
	form.on('submit(saveBtn)', function (data) {
		$.post('/feedback/post/',
			{
				title: data.field.title,
				name: data.field.name,
				phone: data.field.phone,
				content: data.field.content,
				mid: data.field.mid,
				vercode: data.field.vercode,
			}, function (res) {
				if (res.status == 1) {
					layer.confirm(res.info, {
							icon: 6,
							btn: ['知道了'] //按钮
						}, function(){
							location.href = '/feedbacks';
						});
				} else {
					layer.msg(res.info, { icon: 2, anim: 6, time: 2000 });
					$('#recode').attr("src",codeSrc);
				}
			});
		return false;
	});

	//重置验证码
	$('#recode').click(function(){
		this.src = codeSrc;
	});

});
</script>

<import file="block/common.html" name="footer"/>
</body>
</html>